﻿// Models/Question.cs
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WebApplication1.Models
{
    /// <summary>
    /// 试题实体类
    /// </summary>
    [Table("Questions")]
    public class Question
    {
       

        /// <summary>
        /// 试题ID
        /// </summary>
        [Key]
        public int QuestionId { get; set; }

        /// <summary>
        /// 考试ID
        /// </summary>
        [Required]
        public int ExamId { get; set; }

        /// <summary>
        /// 试题内容
        /// </summary>
        [Required]
        [Display(Name = "试题内容")]
        public string QuestionText { get; set; }

        /// <summary>
        /// 试题类型 (Single:单选题, Multiple:多选题, TrueFalse:判断题, Fill:填空题)
        /// </summary>
        [Required]
        [Display(Name = "试题类型")]
        public string QuestionType { get; set; }

        /// <summary>
        /// 分数
        /// </summary>
        [Required]
        [Display(Name = "分数")]
        public int Score { get; set; }

        /// <summary>
        /// 正确答案
        /// 单选题: 选项标识 (如 A)
        /// 多选题: 选项标识列表 (如 A,B,C)
        /// 判断题: True 或 False
        /// 填空题: 答案列表 (如 答案1,答案2,答案3)
        /// </summary>
        [Required]
        [Display(Name = "正确答案")]
        public string CorrectAnswer { get; set; }

        /// <summary>
        /// 考试
        /// </summary>
        public virtual Exam Exam { get; set; }

        /// <summary>
        /// 选项集合
        /// </summary>
        public virtual ICollection<Option> Options { get; set; }

        /// <summary>
        /// 用户答案集合
        /// </summary>
        public virtual ICollection<UserAnswer> UserAnswers { get; set; }

        [DisplayName("是否激活")]
        public bool IsActive { get; set; }

        public Question()
        {
            IsActive = true; // 默认激活
        }
    }
}